// 书签
const state: any = {
  bookmarkList: [],
};

const mutations = {
  setBookmarkList: (state: any, action: any) => {
    state.bookmarkList = action.value;
  },
  addBookmark: (state: any, action: any) => {
    state.bookmarkList.push(action.value);
  },
  deleteBookmark: (state: any, action: any) => {
    let index = state.bookmarkList.findIndex(
      (item: any) => item.id == action.value.id
    );
    state.bookmarkList.splice(index, 1);
  },
};
const actions = {
  SET_BOOKMARKLIST: (dispatch: any, value: any) => {
    let action = {
      type: "setBookmarkList",
      value,
    };
    dispatch.commit(action);
  },
  ADD_BOOKMARK: (dispatch: any, value: any) => {
    let action = {
      type: "addBookmark",
      value,
    };
    dispatch.commit(action);
  },
  DELETE_BOOKMARK: (dispatch: any, value: any) => {
    let action = {
      type: "deleteBookmark",
      value,
    };
    dispatch.commit(action);
  },
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
